package com.csot.job;

import com.csot.model.AssetIdleIp;
import com.csot.model.AssetIp;
import com.csot.model.CityIp;
import com.csot.model.CoarseIp;
import com.jfinal.plugin.activerecord.Db;

import java.util.List;

public class CheckIp {

    private CoarseIp coarseIp = new CoarseIp().dao();

    private CityIp cityIp = new CityIp().dao();

    private AssetIp assetIp = new AssetIp().dao();

    private AssetIdleIp assetIdleIp = new AssetIdleIp().dao();


    public void checkAssetIp() {
        Db.tx(() -> {
            Db.delete("delete from t_asset_idle_ip");
            List<AssetIp> assetIpList = assetIp.find("SELECT * from t_asset_ip a where  not EXISTS(select 1 from t_city_ip b where b.ip_address = a.ip) and not EXISTS (select 1 from t_coarse_ip c where c.ip_address = a.ip)");
            Db.batchSave(assetIpList, 999);
            return true;
        });
    }


}
